package fitdroid.tabs;


import java.util.LinkedList;

import android.app.TabActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.widget.TabHost;
import coderminus.maps.R;

public class TabDemo extends TabActivity {
	static public boolean runsetup =false;
	static public LinkedList<TabHost.TabSpec> tablist;
	static public TabHost tabHost;
	static public LinkedList<Intent> intentlist =new LinkedList<Intent>(); ;
	@Override
	
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		tabHost = getTabHost();
		LayoutInflater.from(this).inflate(R.layout.tab,
				tabHost.getTabContentView(), true);
		
		TabTracker.getInstance().setTabHost(tabHost);
		
		Intent tab_config = new Intent(TabDemo.this, configuration.class);
	    Intent tab_runmanager = new Intent(TabDemo.this, runmanager.class);
	    Intent tab_runsetup = new Intent(TabDemo.this, runsetup.class);
	    Intent tab_exercisemanager = new Intent(TabDemo.this, exercisemanager.class);
	    Intent tab_exercisesetup = new Intent(TabDemo.this, exercisesetup.class);
	    Intent tab_map = new Intent(TabDemo.this, coderminus.maps.MapsActivity.class);
	    Intent tab_runsetuphost = new Intent(TabDemo.this, RunSetupHost.class);
	    
	    intentlist.add(tab_config);
	    intentlist.add(tab_runmanager);
	    intentlist.add(tab_runsetup);
	    intentlist.add(tab_exercisemanager);
	    intentlist.add(tab_exercisesetup);
	    intentlist.add(tab_map);
	    
	    
		 // data structure, what I referred to as memory  
		 tablist = new LinkedList<TabHost.TabSpec>();  
		   
		 //RunTrainer Map+Configuration
		 TabHost.TabSpec spec = tabHost.newTabSpec("tab_gps");  
		 spec.setIndicator("Run Trainer").setContent(tab_runsetup);  
		 //spec.setIndicator("Run Trainer").setContent(tab_runsetuphost); 
		 
		 tabHost.addTab(spec);  
		 tablist.add(spec); 
		 
		 //ExerciseTrainer
		 spec = tabHost.newTabSpec("tab_exercise");  
		 spec.setIndicator("Exercise Trainer").setContent(tab_exercisesetup);

		 tabHost.addTab(spec);  
		 tablist.add(spec); 
		 
		 //Configuration
		 spec = tabHost.newTabSpec("tab_config");  
		 spec.setIndicator("Configuration").setContent(tab_config);

		 tabHost.addTab(spec);  
		 tablist.add(spec); 
		 
		
		 
		 tabHost.setCurrentTab(0);
		/*tabHost.addTab(tabHost.newTabSpec("tab1").setIndicator("tab1")
				.setContent(R.id.view1));

		tabHost.addTab(tabHost.newTabSpec("tab2").setIndicator("tab2",
				getResources().getDrawable(R.drawable.app_sample_code))
				.setContent(R.id.view2));
		tabHost.addTab(tabHost.newTabSpec("tab3").setIndicator("tab3")
				.setContent(
						new Intent(this, coderminus.maps.MapsActivity.class)));
		
		
		
	    if (runsetup)
	    	tabHost.addTab(tabHost.newTabSpec("tab_gps").setIndicator("Run Trainer").setContent(tab_map.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)));
	    else
	    	tabHost.addTab(tabHost.newTabSpec("tab_gps").setIndicator("Run Trainer").setContent(tab_runsetup.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)));
	    //tabHost.addTab(tabHost.newTabSpec("tab_gps").setIndicator("Run Trainer",getResources().getDrawable(R.drawable.minibizeps)).setContent(tab_map));
	    tabHost.addTab(tabHost.newTabSpec("tab_exercise").setIndicator("Exercise Trainer").setContent(tab_exercisemanager));
	    tabHost.addTab(tabHost.newTabSpec("tab_config").setIndicator("Configuration").setContent(tab_config));
	    
	    tabHost.setCurrentTab(0);*/
	}
}
